package com.haoshuang.zhouzhoubang.ui.page.order.take.services

import com.haoshuang.zhouzhoubang.model.api.ApiRepo
import com.haoshuang.zhouzhoubang.model.bean.ChooseServiceBean
import com.mufeng.libs.base.BaseViewModel
import com.mufeng.libs.net.ResponseBean
import com.mufeng.libs.net.netRequest
import com.mufeng.libs.state.StateData
import com.mufeng.libs.state.StatefulMutableLiveData

class ChooseServicesViewModel : BaseViewModel() {

    /**
     * 获取所有服务列表
     */
    val getAllSkillListData = StatefulMutableLiveData<ResponseBean<MutableList<ChooseServiceBean>>>()
    fun getAllSkillList() = netRequest {
        start { getAllSkillListData.value = StateData.Loading }
        request { ApiRepo.getAllSkillList()  }
        success { getAllSkillListData.value = StateData.Success(it) }
        error { code, msg ->
            getAllSkillListData.value = StateData.Error(code, msg)
        }
    }
}